#pragma once

#include  "iostream"
#include  "vector"
#include  "stack"
#include  "unordered_map"
#include   "queue"
#include "TypeDefin.h"

using namespace std;
TreeNode *r = nullptr;

void flatten(TreeNode *root) {

    if (!root)
        return;
    auto t = root->right;
    if (r == nullptr)
        r = root;
    else {
        r->right = root;
        r = root;
    }

    flatten(root->left);
    flatten(t);

}